package com.lc.rongzecaifu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.conn.JsonCapital;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 3/16/2016.
 */
public class MyAssetsHistoryAdapter extends RecyclerView.Adapter<MyAssetsHistoryAdapter.ViewHolder> {

    private Context context;
    private List<JsonCapital.Info.ListContent> loglist;

    public MyAssetsHistoryAdapter(Context context, List<JsonCapital.Info.ListContent> loglist) {
        this.context = context;
        this.loglist = loglist;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case

        @Bind(R.id.tv_edit_01)
        TextView tvEdit01;
        @Bind(R.id.tv_06)
        TextView tv06;
        @Bind(R.id.tv_07)
        TextView tv07;
        @Bind(R.id.tv_08)
        TextView tv08;
        @Bind(R.id.tv_01)
        TextView tv01;
        @Bind(R.id.tv_02)
        TextView tv02;
        @Bind(R.id.tv_03)
        TextView tv03;
        @Bind(R.id.tv_05)
        TextView tv05;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.list_12_item_view, null)));
        // set the view's size, margins, paddings and layout parameters
        ViewHolder vh = new ViewHolder(view);
        return vh;
    }


    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv01.setText(loglist.get(position).type);//"类型：" +
        holder.tv02.setText(loglist.get(position).add_time);//"发生日期：" +
        holder.tv03.setText(loglist.get(position).info);//"说明：" +
        holder.tv05.setText(loglist.get(position).affect_money);
        holder.tv06.setText(loglist.get(position).account_money);
        holder.tv07.setText(loglist.get(position).freeze_money);
        holder.tv08.setText(loglist.get(position).collect_money);

    }

    @Override
    public int getItemCount() {
        return loglist.size();
    }
}